/**
 * Created by Administrator on 2015/12/22 0022.
 */

var express = require('express');
var router = express.Router();
var request = require('request');
var async = require('async');


router.get('/:id1', function(req, res, next) {
    global.id1 = req.params.id1;
    async.series([
        function (callback) {
            var reqUrl = "http://10.32.18.68:8000/host-info/?vcenter=" + global.id1 + "";
            request({uri: reqUrl}, function (error, response, body) {
                var str1 = JSON.parse(body);
                callback(null, str1);
            })
        },
        function (callback) {
            var reqUrl = "http://10.32.18.68:8000/vc-info/?vcenter=" + global.id1 + "";
            request({uri: reqUrl}, function (error, response, body) {
                var str2 = JSON.parse(body);
                callback(null, str2);
            })
        }],
        function(err,result) {
            console.log(result);
            res.render('vc',{
                title:'vc',
                msg1:result[0],
                msg2:result[1]
            })
        }

    )

});

module.exports = router;


